<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="!crud.props.searchToggle">
        <el-form size="small" label-width="70px">
          <el-row :gutter="10">
<!--            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">-->
<!--              <el-form-item label="仓库人员">-->
<!--                <table-select-->
<!--                  :tableColumns="-->
<!--                  [-->
<!--                  {prop:'code',label:'人员编码',width: '100'},-->
<!--                  {prop:'name',label:'人员名称',width: '150'},-->
<!--                  ]"-->
<!--                  labelKey="name"-->
<!--                  valueKey="id"-->
<!--                  width="400"-->
<!--                  :value.sync="query.userIds"-->
<!--                  placeholder="请选择人员"-->
<!--                  url="api/dropDown/sysUserList"-->
<!--                />-->
<!--              </el-form-item>-->
<!--            </el-col>-->
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
                <el-form-item label="选择年月" >
                  <el-date-picker
                    v-model="month"
                    type="month" @change="getYear"
                    :clearable="false"
                    placeholder="选择年"/>
                </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <rrOperation :crud="crud"/>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <crudOperation :permission="permission">
        <el-button
          type="primary"
          slot="right"
          class="filter-item"
          size="mini"
          @click="adjust()"
          v-permission="permission.adjust"
          :disabled="crud.selections.length > 1"
        >
          调整
        </el-button>
      </crudOperation>
      <!--表单组件-->

      <el-dialog
        :close-on-click-modal="false"
        :before-close="crud.cancelCU"
        :visible.sync="crud.status.cu > 0"
        :title="crud.status.title"
      >
        <el-form
          ref="form"
          :model="form"
          :rules="rules"
          size="small"
          label-width="80px"
        >
          <div class="flex flex-row">
            <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
              <el-form-item label="客户" prop="customerId">
                <zSelect  :value.sync="form.customerId"  url="/api/dropDown/basCustomerList"
                          :params="{type:1}" style="width:  100%;"/>
              </el-form-item>
              <el-form-item label="商品" prop="goodsId">
                <zSelect :value.sync="form.goodsId" :showName="form.goodsName" valueKey="goodsId" labelKey="goodsName" url="/api/dropDown/basGoodsListForAdd"
                         v-model="form.goodsId"
                         :params="{packageType:2}" style="width:  100%;"/>
              </el-form-item>
            </el-col>

            <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
              <el-form-item label="出入库类型">
                <el-select
                  v-model="form.type"
                  clearable
                  class="edit-input"
                  placeholder="入库/出库"
                >
                  <el-option
                    v-for="(item, index) in options"
                    :key="index"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
              <el-form-item label="调整数量">
                <el-input v-model="form.goodsCount" />
              </el-form-item>
            </el-col>
          </div>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button
            :loading="crud.cu === 2"
            type="primary"
            @click="submitAdjust"
          >确认</el-button
          >
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table"
                stripe border
                v-loading="crud.loading"
                :data="crud.data"
                size="small"
                style="width: 100%;"
                @selection-change="crud.selectionChangeHandler"
                :cell-style="{'text-align':'center'}"
      >
        <el-table-column type="selection" width="55" />
        <el-table-column type="index" width="55" label="序号"/>
        <!--        <el-table-column v-if="columns.visible('id')" prop="id" label="id" />-->
        <el-table-column prop="name" label="人员名称" />
        <el-table-column prop="pickBoxCount" label="拣货箱数" />
        <el-table-column prop="pickNum" label="拣货条码数" />
        <el-table-column prop="checkBoxCount" label="核对箱数" />
        <el-table-column prop="checkNum" label="核对条码数" />
        <el-table-column prop="groundBoxCount" label="上架箱数" />
        <el-table-column prop="groundNum" label="上架条码数" />
        <el-table-column prop="returnBoxCount" label="退货箱数" />
        <el-table-column prop="returnNum" label="退货条码数" />

      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudPlasticDeposit from '@/api/erp/reportWarePersonsAppraise'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

const date = new Date()
const curYear = date.getFullYear()
const curMonth = date.getMonth() + 1
// crud交由presenter持有
const defaultCrud = CRUD({
  title: '仓库考核',
  url: 'api/reportWarehouseAssessment',
  sort: '',
  crudMethod: { ...crudPlasticDeposit },
  query:{
    year:curYear,
    month:curMonth,
    userIds:'',
    deptIds:''
  },
  optShow: {
    add: false,
    edit: false,
    del: false,
    download: true,
    downloadDetail: false,
    leadingIn: false,
    enable: false,
    disable: false,
    pass: false,
    reject: false,
  }
})
const defaultForm = { id: null, customerId: null, goodsId: null, goodsCount: null, createTime: null, updateTime: null, companyId: null }
export default {
  name: 'reportWarePersonsAppraise',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(defaultCrud), header(), form(defaultForm), crud()],
  data() {
    return {
      chooseCustomer: [],
      permission: {
        add: ['admin', 'plasticDeposit:add'],
        edit: ['admin', 'plasticDeposit:edit'],
        del: ['admin', 'plasticDeposit:del'],
        import: ['admin', 'plasticDeposit:import'],
        export: ['admin', 'plasticDeposit:export'],
        copy: ['admin', 'plasticDeposit:copy'],
        upload: ['admin', 'plasticDeposit:upload'],
        download: ['admin', 'plasticDeposit:download'],
        adjust: ['admin', 'plasticDeposit:adjust'],
      },
      month:""
          }
  },
  watch: {
  },
  created(){
    this.month = `${date.getFullYear()}-${date.getMonth()<9?"0"+(date.getMonth() + 1):date.getMonth() + 1}`
  },
  methods: {
    getYear(e){
      const date = new Date(e)
      this.crud.query.year = date.getFullYear()
      this.crud.query.month = date.getMonth() + 1
      this.month = `${date.getFullYear()}-${date.getMonth()<9?"0"+(date.getMonth() + 1):date.getMonth() + 1}`
    },
    // 获取数据前设置好接口地址
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }, // 新增与编辑前做的操作
    [CRUD.HOOK.afterToCU](crud, form) {
    },
  }
}
</script>

<style scoped>
.table-img {
  display: inline-block;
  text-align: center;
  background: #ccc;
  color: #fff;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  vertical-align: middle;
  width: 32px;
  height: 32px;
  line-height: 32px;
}
</style>
